
package com.joysuch.wwyt.core.security;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.io.Serializable;
import java.util.List;

/**
 * 自定义Authentication对象，使得Subject除了携带用户的登录名外还可以携带更多信息.
 *
 */
public class ShiroUser implements Serializable {
    private static final long serialVersionUID = 1L;

    // 租户ID
    private Long tenentId;

    public Long id;
    // 真实用户ID BaseUser
    private Long realUserId;
    public String username;
    // name: 用户昵称; id: 用户id, auth: 权限/菜单数组, company: 公司 jobId: 岗位id; jobName: 岗位名称
    private String companyName;
    private Long companyId;
    private String companyCode;
    private String jobName;
    private Long jobId;
    private Long departId;
    private String departName;
    private String departCode;
    // 超级管理员
    private boolean superAdmin;
   //真实姓名
    private String realName;
    //角色IDs
    private List<Long> roleIds;

    //工号
    private String code;


    public ShiroUser(Long id, Long realUserId, String username) {
        this.id = id;
        this.username = username;
        this.realUserId = realUserId;
    }

    public ShiroUser() {

    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public String getCompanyCode() {
        return companyCode;
    }

    public void setCompanyCode(String companyCode) {
        this.companyCode = companyCode;
    }

    public Long getRealUserId() {
        return realUserId;
    }

    public void setRealUserId(Long realUserId) {
        this.realUserId = realUserId;
    }

    public String getJobName() {
        return jobName;
    }

    public void setJobName(String jobName) {
        this.jobName = jobName;
    }

    public Long getJobId() {
        return jobId;
    }

    public void setJobId(Long jobId) {
        this.jobId = jobId;
    }

    public Long getDepartId() {
        return departId;
    }

    public void setDepartId(Long departId) {
        this.departId = departId;
    }

    public String getDepartName() {
        return departName;
    }

    public void setDepartName(String departName) {
        this.departName = departName;
    }

    public String getDepartCode() {
        return departCode;
    }

    public void setDepartCode(String departCode) {
        this.departCode = departCode;
    }

    @Override
    public String toString() {
        return username;
    }

    public Long getTenentId() {
        return tenentId;
    }

    public void setTenentId(Long tenentId) {
        this.tenentId = tenentId;
    }

    public String getRealName() {  return realName; }

    public void setRealName(String realName) { this.realName = realName; }

    // 是否超级管理员
    public boolean isSuperAdmin() {
        return superAdmin;
    }

    public void setSuperAdmin(boolean superAdmin) {
        this.superAdmin = superAdmin;
    }

    public List<Long> getRoleIds() { return roleIds;   }

    public void setRoleIds(List<Long> roleIds) {this.roleIds = roleIds;  }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this, "username");
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj, "username");
    }
}
